<template>
  <div class="boy">
    <h3>男人组件</h3>
    <div>金钱：{{ money }}</div>
    <button @click="addMoney">搬砖+1</button>
    <button @click="addMoreMoney(100)">卖肾+100</button>
  </div>
</template>

<script>
import { mapMutations } from "vuex";
export default {
  computed: {
    money() {
      return this.$store.state.money;
    },
  },
  methods: {
    // **辅助函数** - mapMutations
    ...mapMutations(["addMoney", "addMoreMoney"]),
    // addFn() {
    //   // 提交mutations用commit
    //   this.$store.commit("addMoney");
    // },
    // addMoreFn() {
    //   this.$store.commit("addMoreMoney",  100 );
    // },
  },
};
</script>

<style>
button {
  padding: 5px;
  line-height: 30px;
  margin-left: 10px;
}
</style>
